# coding=utf-8
# 代码文件：chapter5/ch5.4.8.py

import pandas as pd

f = r'data/北京房价数据.xlsx'

df = pd.read_excel(f)

df2 = df.query("城区!= '北京周边'")
grouped_df = df2.groupby(['城区'])

df3 = grouped_df.mean().sort_values(by='单价（元）', ascending=False)

f = r'data/temp.csv'

df3.to_csv(f, encoding='gbk')

print('Game Over')
